/*
 * scalar.h
 *
 *  Created on: Sep 17, 2008
 *      Author: lindenb
 */

#ifndef SCALAR_H_
#define SCALAR_H_

#ifdef  __cplusplus
extern "C" {
#endif

enum ScalarType
	{
	SCALAR_IS_FLOATING,
	SCALAR_IS_INTEGER,
	SCALAR_IS_STRING
	};
typedef double scalar_double_t;
typedef long scalar_int_t;

typedef struct scalar_t
	{
	enum ScalarType type;
	union
		{
		scalar_double_t floating;
		scalar_int_t integer;
		char* string;

		} value;
	}Scalar,*ScalarPtr;

extern ScalarPtr  ScalarNewString(const char *s);
extern ScalarPtr  ScalarNewDouble(scalar_double_t d);
extern ScalarPtr  ScalarNewInt(scalar_int_t L);
extern void ScalarDelete(ScalarPtr ptr);
extern ScalarPtr ScalarClone(const ScalarPtr ptr);
extern int ScalarCompare(const ScalarPtr a, const ScalarPtr b);
/**
 * print a scalar to the given stream
 * @param ptr the scalar to print
 * @param out the stream
 * @return 0 if no problem
 */
extern int ScalarPrint(const ScalarPtr ptr,FILE* out);

#ifdef  __cplusplus
extern }
#endif


#endif /* SCALAR_H_ */
